<!DOCTYPE html>
<head>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<style>
.composited {
will-change: transform;
}

.box {
  width: 100px;
  height: 100px;
}

.behind {
  position: absolute;
  z-index: 1;
  top: 50px;
  left: 50px;
  background-color: blue;
}

.top {
  position: absolute;
  z-index: 1;
  top: 130px;
  left: 130px;
  background-color: cyan;
}

#inner {
  position:absolute;
  top:10px;
  left: 10px;
  height: 50px; width: 50px;
  background-color: lightslategray;
  z-index: 2
}

</style>
<script>
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    function runTest()
    {
        runAfterLayoutAndPaint(executeTestCases);
    }

    function executeTestCases()
    {
        internals.startTrackingRepaints(document);
        document.getElementById('Case1').textContent = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_INVALIDATIONS);
        internals.stopTrackingRepaints(document);

        internals.startTrackingRepaints(document);
        document.querySelector("#inner").style.backgroundColor = 'red';
        document.getElementById('Case2').textContent = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_INVALIDATIONS);
        internals.stopTrackingRepaints(document);

        // Display the test results only after test is done so that it does not affect repaint rect results.
        document.getElementById('testResults').style.display = "block";

        if (window.testRunner)
            testRunner.notifyDone();
    }
</script>
</head>
<body onload="runTest()">
  <div class="composited box behind"></div>

  <div class="box top">
    <div id="inner">
    </div>
  </div>

  <div id="testResults" style="display:none">
    CASE 1, original layer tree
    <pre id="Case1"></pre>

    CASE 2, change color of "inner" to red
    <pre id="Case2"></pre>
  </div>
</body>
